#!/bin/bash

echo '开放端口'
firewall-cmd --zone=public --add-port=6371-6376/tcp --permanent
firewall-cmd --zone=public --add-port=16371-16376/tcp --permanent
firewall-cmd --reload

# 主机ip
ip=$(ip addr | grep ens | awk -F ' ' 'NR==2{print $2}' | awk -F '/' '{print $1}')
dirs=$(ls init/redis)

echo "修改redis配置文件 主机ip为:$ip"
for file in $dirs; do
  sed -i "/^cluster-announce-ip/c cluster-announce-ip $ip" init/redis/$file/redis.conf
done

echo '启动容器'
docker-compose up -d

echo '查看容器'
docker-compose ps
